package com.example.ad_project;

import java.util.Date;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.nus.iss.ad.model.OrderDetail;
import com.nus.iss.ad.model.RequestDetail;

public class RequestDetailAdapter extends ArrayAdapter<RequestDetail> {
	 private Context context;
		private RequestDetail[] values;

		public  RequestDetailAdapter(Context context, RequestDetail[] values) {
		   super(context, R.layout.request_detail_row, values);
		   this.context = context;
		   this.values = values;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
	        View v=convertView;
	        if (convertView == null) {
	        	LayoutInflater inflater = ((Activity)context).getLayoutInflater();
	            v = inflater.inflate(R.layout.request_detail_row, null);
	        }

	        
	        TextView tCode = (TextView)v.findViewById(R.id.textViewCode);
	        TextView tName = (TextView)v.findViewById(R.id.textViewName);
	        TextView tQty = (TextView)v.findViewById(R.id.textViewQty);
	        TextView tStock = (TextView)v.findViewById(R.id.textViewStock);
	        CheckBox c1=(CheckBox)v.findViewById(R.id.checkBox1);
	        
	        RequestDetail rd=values[position];
	        String code=rd.getInventoryId();
	        String name=rd.getInventory().getDescription();
	        String qty=Integer.toString(rd.getQuantity());
	        String stock=Integer.toString(rd.getInventory().getStock());
	        tCode.setText(code);
	        tName.setText(name);
	        tQty.setText(qty);
	        tStock.setText(stock);
	       
	        return v;
			
		}
}
